package YAPserver.mods;

import YAPenvironment.YAPconstant.ModState;
import YAPserver.gameObjects.GameBall;
import YAPserver.gameObjects.Mod;
import YAPserver.gameObjects.Point;
import YAPserver.logic.GameModifier;
import YAPserver.logic.Player;
/**
 * A global ModBehaviour.
 * When this modBehaviour's modify method is called the first gameBall in the balls list splits radially into eight balls with a normalised speed of eight.
 * The demodify method is empty.
 * @author Daniel
 *
 */
public class ModEightBall extends AbstractStandardMod{

	@Override
	public void modify(Mod mod, GameModifier gameMod, Player player) {
		super.modify(mod, gameMod, player);
		//now for some fun
		//this is the point my 8 balls will radiate from
		Point middlePoint = new Point(gameMod.getBalls(0).getMiddlePoint());
		double angle = gameMod.getBalls(0).getLine().getAngle();
		double radius = gameMod.getBalls(0).getRadius();
		
		for(int i=0; i<8; i++){
			gameMod.addBall(new GameBall(new Point(middlePoint), 2.*Math.PI/8.*i+angle, 8, radius));
		}
		//remove original ball, this way it looks like an explosion :D
		gameMod.removeBall(0);
	}

	@Override
	public void deModify(Mod mod, GameModifier gameMod, Player player) {
		//do nothing
	}

	@Override
	public ModState getType() {
		return ModState.global;
	}
}
